package com.xpgk.mvc.personalInformation;

import java.util.HashMap;
import java.util.Map;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.intoPersonnel.IntoPersonnel;
import com.xpgk.mvc.intoPersonnel.IntoPersonnelServices;
import com.xpgk.mvc.user.User;
import com.xpgk.mvc.user.UserService;
public class PersonalInformationController extends BaseController{
	public void index(){	
		String userids=getCUserIds();
		User user=User.dao.findById(userids);
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("column", IntoPersonnel.column_userIds);
		String sql=getSqlByBeetl(IntoPersonnel.sqlId_column,param);
		IntoPersonnel personnel=IntoPersonnel.dao.findFirst(sql,userids);
		setAttr("user",user);
		setAttr("intoPersonnel",personnel);
		render("personalInformation.html");
	}
	
	private IntoPersonnelServices intoPersonnelServices=new IntoPersonnelServices();
	private UserService userService;
	
	/**
	 * 保存基本信息
	 */
	@Before(Tx.class)
	public void saveIntoPer(){
		String personalInfoIds=getPara("personalInfo.userIds");
		//获取当前登录机构id
		String cudid=getCUserOrganIds();
		IntoPersonnel intoPersonnel=getModel(IntoPersonnel.class,"intoPersonnel");
		RenderBean result=intoPersonnelServices.saveIntoPer(intoPersonnel,personalInfoIds,cudid);
		renderJson(result.getMap());
	}
	/**
	 * 更改密码
	 */
	public void alter(){
		render("alterPassword.html");
	}
	
	/**
	 * 登录更改密码
	 */
	public void alterLogin(){
		String userName = getPara("userName");
		setAttr("username", userName);
		render("updatePassword.html");
	}
}
